const app = getApp()
Page({
    data: {
        jokeMessageList:[]
    },
    onLoad(){
        this.setData({
            canIUseGetUserProfile: true,
            nbTitle: '十万个冷笑话',
          nbLoading: true,
          nbFrontColor: '#ffffff',
          nbBackgroundColor: '#000000'
          })
        wx.request({
            url: 'https://guitarfish.top/applet/jokesApi/getJokesList',
            method: 'GET',
            header: {
              'Content-Type': 'application/json'
            },
            success: res=> {
              console.log(res.data.data); // 打印请求成功后返回的数据
              this.setData({
                jokeMessageList:res.data.data,
                nbLoading:false
              })
            },
            fail: error=> {
              console.log(error); // 打印请求失败的错误信息
            }
          });
    },
    onReachBottom() {
        this.setData({
            nbLoading:true
          })
        // 当页面滚动到底部时触发的事件
        wx.request({
            url: 'https://guitarfish.top/applet/jokesApi/getJokesList',
            method: 'GET',
            header: {
              'Content-Type': 'application/json'
            },
            success: res=> {
              console.log(res.data.data); // 打印请求成功后返回的数据
              const newDataList =this.data.jokeMessageList.concat(res.data.data)
              this.setData({
              jokeMessageList:newDataList,
              nbLoading:false
              })
            },
            fail: error=> {
              console.log(error); // 打印请求失败的错误信息
            }
          });
      }
})